package com.project.service;

import com.project.bean.StudentBean;
import com.project.dao.IStuDao;
import com.project.server.Request;
import com.project.server.Response;
import com.project.util.DaoFactory;
import com.project.util.WebServlet;

@WebServlet("findByClassId")
public class FindByClassIdService {
    /**
     * 持久组件
     */
    private IStuDao dao = (IStuDao) DaoFactory.getDao("IStuDao");

    public void service(Request req, Response resp){
        //得到表单数据
        int id = Integer.parseInt(req.getParameter("id"));
        //调用持久方法，得到结果
        StudentBean stu = dao.findByClassName();

        String str ="<form action='findByClassId'>";
        str += "<input type='hidden' name='id' value='"+id+"'>";
        str += "姓名:"+stu.getStuName()+"<br>";
        str += "班级:"+stu.getClassBean().getClassName()+"<br>";
        str+="</form>";
        resp.sendMessage(str);
    }
}
